﻿using System.Net.NetworkInformation;

namespace NetEnvironmentVariable;

public static class AnacondaEV
{
    public static void Set(string rootPath)
    {
        bool isExists = true;//假定存在
        //1.判断当前目录是否有 Scripts 目录
        var rtPath = Path.GetFullPath(rootPath).Replace(@"\\", @"\");
        string pathExists = Path.Combine(rtPath, "Scripts");
        if (Directory.Exists(pathExists) == false)
        {
            Console.WriteLine("Anaconda缺少Scripts目录！");
            isExists = false;
        }

        pathExists = Path.Combine(rtPath, "Library");
        if (Directory.Exists(pathExists) == false)
        {
            Console.WriteLine("Anaconda缺少Library目录！");
            isExists = false;
        }

        if(isExists == false)
        {
            Console.WriteLine("Anaconda环境配置失败！");
            return;
        }

        //2.在 Path 中 添加 "\Scripts" 和 "\Library\mingw - w64\bin"  \Library\usr\bin  \Library\bin
        EV.SetByKey("Path", @$"{rtPath}\Scripts;{rtPath}\Library\mingw - w64\bin;{rtPath}\Library\usr\bin;{rtPath}\Library\bin;");

        Console.WriteLine("Anaconda环境配置完成!");
    }
}
